﻿using Aeon.Emulator.Sound.FM.Operators;

namespace Aeon.Emulator.Sound.FM.Channels
{
    /// <summary>
    /// Emulates a 2-operator bass drum rhythm OPL channel.
    /// </summary>
    internal sealed class BassDrum : Channel2
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="BassDrum"/> class.
        /// </summary>
        /// <param name="opl">The synthesizer which owns the channel.</param>
        public BassDrum(FmSynthesizer opl)
            : base(6, new StandardOperator(0x10, opl), new StandardOperator(0x13, opl), opl)
        {
        }

        /// <summary>
        /// Activates the bass drum channel output.
        /// </summary>
        public void BassDrumKeyOn()
        {
            this.operator1.KeyOn();
            this.operator2.KeyOn();
        }

        /// <summary>
        /// Returns an array containing the channel's output values.
        /// </summary>
        /// <returns>Array containing the channel's output values.</returns>
        protected override double GetChannelOutput()
        {
            if(this.OperatorCount == 1)
                this.operator1.AttackRelease = 0;

            return base.GetChannelOutput();
        }
        /// <summary>
        /// Activates channel output.
        /// </summary>
        protected override void KeyOn()
        {
        }
        /// <summary>
        /// Disables channel output.
        /// </summary>
        protected override void KeyOff()
        {
        }
    }
}
